********Figure 2 - Indonesia********

cd "$reploc/data"
use Indo_prov_timeseries.dta, clear

append using Indo_timeseries.dta
drop idind

replace countryname="Indonesia" if countryname==""
replace provcode93=111111 if countryname=="Indonesia"

forval yr=1960/1975 {
gen gdp`yr'=.
}


forval yr=1960/2014 {
replace gdp`yr'=indo_gdp`yr' if provcode93==111111
}

drop indo_gdp*

reshape long gdpgr gdp, i(provcode93) j(year)

*Keep provinces we are interested in
rename provcode93 PROVCODE
drop if PROVCODE == 82
drop if PROVCODE == 91
drop if PROVCODE == 92


*Winsorize data
winsor gdpgr if PROVCODE!=111111, p(0.05) gen(gdpgr_wins)
sort PROVCODE year


*Create GDP growth for Indonesia
replace gdpgr=((gdp-gdp[_n-1])/gdp[_n-1])*100 if PROVCODE==111111 & year>1960
replace gdpgr_wins=gdpgr if PROVCODE==111111


*Plot
tsset PROVCODE year
drop if year<1977

local provcodesgrey 11 13 14 15 16 17 18 31 32 34 35 51 52 53 61 62 63 64 71 72 73 74 81

local plotinum (line gdpgr_wins year if PROVCODE==13, lcolor(gs12))
local legi legend()

foreach progrey in `provcodesgrey' {
local plotinum `plotinum' (line gdpgr_wins year if PROVCODE==`progrey', lcolor(gs12))
local legi `legi' label(1 "")
}

local plotinum1 `plotinum' (line gdpgr_wins year if PROVCODE==12, lcolor(orange) lwidth(#10)) (line gdpgr_wins year if PROVCODE==33, lcolor(magenta) lwidth(#10)) (line gdpgr_wins year if PROVCODE==111111, lcolor(black) lwidth(medthick))

twoway `plotinum1', legend(order(25 "North Sumatra" 26 "Central Java" 27 "Indonesia") rows(1)) ytitle("GDP Growth (%)") xtitle("Year") graphregion(color(white)) 

cd "$reploc/results"
graph export Figure2Indonesia.eps, replace












